﻿using UnityEngine;
using System.Collections;

public class LevelPartInfo : Actor
{
	/// <summary>
	/// The Start Background visual. Must be considered as the beginning limit of the level part.
	/// </summary>
	public SpriteRenderer m_StartBackgroundVisual;
	/// <summary>
	/// The End Background visual. Must be considered as the ending limit of the level part.
	/// </summary>
	public SpriteRenderer m_EndBackgroundVisual;
	
	public float MinX
	{
		get { return m_StartBackgroundVisual.bounds.min.x; }
	}
	public float MaxX
	{
		get { return m_EndBackgroundVisual.bounds.max.x; }
	}

	public delegate void Callback();
	public Callback m_OnLevelStart;
	public Callback m_OnLevelEndReached;

	public LevelManager.LevelType m_Type;

	[HideInInspector]
	public bool m_LevelEndReached = false;

	protected override void Awake () 
	{
		base.Awake();
	}
	
	// Update is called once per frame
	void Update () 
	{
	
	}
	
	public void OnLevelStart()
	{
		if(m_OnLevelStart != null) m_OnLevelStart();
	}

	public void OnLevelEndReached()
	{
		if(!m_LevelEndReached)
		{
			m_LevelEndReached = true;
			if(m_OnLevelEndReached != null) m_OnLevelEndReached();
		}
	}
}
